package com.rykj.qxj.test.xtest;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;

public class ArrayCompute {
	
	public static void main(String[] args) {
		 List<List<String>> list = new ArrayList<List<String>>();
		 
		 String start="aa/bb/cc/dd/ee/ff/*";
		 String end="gg/dd/ff/bb";
         
         List<String> listSub1 = Arrays.asList(start.split("/"));
         List<String> listSub2 = Arrays.asList(end.split("/"));

         list.add(listSub1);
         list.add(listSub2);
         List<List<String>> result = new ArrayList<List<String>>();
         descartes(list, result, 0, new ArrayList<String>());
         System.out.println(JSON.toJSONString(result));
         System.out.println("======================================");
         System.out.println(result);
         System.out.println("========================================");
         for (List<String> list2 : result) {
        	  System.out.println("==============================");
        	  System.out.println(list2.get(0)+"-"+list2.get(1));
			
		}
	}
	
	private static void descartes(List<List<String>> dimvalue, List<List<String>> result, int layer, List<String> curList) {
        if (layer < dimvalue.size() - 1) {
            if (dimvalue.get(layer).size() == 0) {
                descartes(dimvalue, result, layer + 1, curList);
            } else {
                for (int i = 0; i < dimvalue.get(layer).size(); i++) {
                    List<String> list = new ArrayList<String>(curList);
                    list.add(dimvalue.get(layer).get(i));
                    descartes(dimvalue, result, layer + 1, list);
                }
            }
        } else if (layer == dimvalue.size() - 1) {
            if (dimvalue.get(layer).size() == 0) {
                result.add(curList);
            } else {
                for (int i = 0; i < dimvalue.get(layer).size(); i++) {
                    List<String> list = new ArrayList<String>(curList);
                    list.add(dimvalue.get(layer).get(i));
                    result.add(list);
                }
            }
        }
	}

}
